resource "google_healthcare_dataset" "dataset" {
  location = "us-central1"
  name     = "<%= ctx[:vars]['dataset_id'] %>"
}

resource "google_healthcare_consent_store" "<%= ctx[:primary_resource_id] %>" {
  dataset = google_healthcare_dataset.dataset.id
  name    = "<%= ctx[:vars]['consent_id'] %>"
}

resource "google_service_account" "test-account" {
  account_id   = "<%= ctx[:vars]['account_id'] %>"
  display_name = "Test Service Account"
}

resource "google_healthcare_consent_store_iam_member" "test-iam" {
  dataset          = google_healthcare_dataset.dataset.id
  consent_store_id = google_healthcare_consent_store.<%= ctx[:primary_resource_id] %>.name
  role             = "roles/editor"
  member           = "serviceAccount:${google_service_account.test-account.email}"
}
